require 'java'

class Directory
  def initialize(directory)
    @directory = directory
  end

  def files(&block)
    contents.each do |file|
      yield PicoUnitFile.from_java(file)
    end
  end

  private
  def contents
  	java.io.File.new(@directory).listFiles
  end
end

class PicoUnitFile
  def self.from_java(file)
    PicoUnitFile.new(file.absolute_path)
  end
  
  def initialize(file)
    @file = file
  end
  
  def matches(pattern)
    !(pattern =~ @file).nil?
  end
end

